package cz.muni.fi.hauntedhouses;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author Andrea Vasekova, 325181
 */
@Entity
public class Human implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    private String name;
    
    @Column(nullable=false,columnDefinition="VARCHAR(6)")
    @Enumerated(EnumType.STRING)
    private Gender gender;
    
    //0 to 100%; indicates the extent to which the Human has already been scared
    private float scareMeter = 0;
    
    //0 to 100%; the higher the resistance, the more difficult it is for the Ghost to scare the Human
    private float resistance;
    
    //if set (=not null), this kind of fear adds more to this Human's scareMeter than other fears
    @Enumerated(EnumType.STRING)
    private Fear worstFear;
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public float getScareMeter() {
        return scareMeter;
    }

    public void setScareMeter(float scareMeter) {
        this.scareMeter = scareMeter;
    }

    public float getResistance() {
        return resistance;
    }

    public void setResistance(float resistance) {
        this.resistance = resistance;
    }

    public Fear getWorstFear() {
        return worstFear;
    }

    public void setWorstFear(Fear worstFear) {
        this.worstFear = worstFear;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Human)) {
            return false;
        }
        Human other = (Human) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Human[id=" + id + ", " + gender + ", name=" + name + ", worst fear=" + worstFear + ", resistance=" + resistance
                + ", scared " + scareMeter + "%]";
    }
    
}
